home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 30
/
Aminet 30 (1999)(Schatztruhe)[!][Apr 1999].iso
/
Aminet
/
dev
/
c
/
EGCSWOSAlib.lha
/
src.lha
/
strnicmp.c
< prev
next >
Wrap
C/C++ Source or Header
|
1999-01-06
|
836b
|
33 lines
#include <ctype.h>
#include <string.h>
/*
** strnicmp() - Compare n nr of chars in two strings incasesensitivly.
**
** Made by Kasper B. Graversen (c) 1996
**
** fixed by phx 01/98
**
** This is freeware - use at own risc.
*/
int strncasecmp(const char *str1, const char *str2, size_t n)
{
if(n==0) return 0;
while(--n && tolower((unsigned char)*str1)==tolower((unsigned char)*str2)){
if(!*str1) return(0);
str1++;str2++;
}
return(tolower(*(unsigned char *)str1)-tolower(*(unsigned char *)str2));
}
int strnicmp(const char *str1, const char *str2, size_t n)
{
if(n==0) return 0;
while(--n && tolower((unsigned char)*str1)==tolower((unsigned char)*str2)){
if(!*str1) return(0);
str1++;str2++;
}
return(tolower(*(unsigned char *)str1)-tolower(*(unsigned char *)str2));
}